from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
import math

X,y = load_iris(return_X_y=True)
X_train,X_test,y_train,y_test = train_test_split(X,y,test_size=0.2)

# 计算新来的一朵花[6.15，3.14,1.56,0.95]属于什么亚科
# p(y0|x) = p(y0)p(6.15|y0)p(3.14|y0)p(1.56|y0)p(0.95|y0)
p_y0 = y_train[y_train == 0]            # 查询y_train中等于0的个数
p_y0 = len(p_y0) / len(y_train)
print(p_y0)
m_0_y0 = (X_train[y_train == 0][:,0]).mean()
std_0_y0 = (X_train[y_train == 0][:,0]).std()

def gaussian_pdf(x, mu, sigma):
    trem1 = 1.0/(sigma*math.sqrt(2.0 * math.pi))
    term2 = math.exp(-0.5 * ((x - mu) / sigma) ** 2)
    return trem1 * term2

p_615_y0 = gaussian_pdf(6.15,m_0_y0,std_0_y0)
# p(y1|x)
# p(y2|x)